package com.project.zhuzhou.news;

import java.util.ArrayList;
import java.util.List;

import com.example.zhuzhou.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class NewsRelatedAdapter extends BaseAdapter {
	
	private Context context;
	private List<RelatedNews> relatedNews;
	
	

	public NewsRelatedAdapter(Context context,List<RelatedNews> relatedNews) {
		super();
		this.context = context;
		this.relatedNews = relatedNews;
	}

	@Override
	public int getCount() {
		return relatedNews.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final RelatedViewHolder viewHolder;
		if(convertView==null){
			viewHolder=new RelatedViewHolder();
			convertView=LayoutInflater.from(context).inflate(R.layout.news_releated_item, null);
			viewHolder.title=(TextView) convertView.findViewById(R.id.relatedNews);
			convertView.setTag(viewHolder);
					
		}else{
			viewHolder=(RelatedViewHolder) convertView.getTag();
		}
		viewHolder.title.setText(relatedNews.get(position).getTitle());
		return convertView;
	}
	
	class RelatedViewHolder{
		TextView title;
	}
}
